##
## june 21,2004: started this thinking i might need a way
## to tell which web-form goes with what user, but i think
## Twisted probably takes care of this -- need to test, though
##

import time
import sha

INTERFACES = {}

def find(hash):
    global INTERFACES
    try:
        return INTERFACES[hash]
    except:
        pass
    return None

class Interface:

    def __init__(self,user):
        self.user = user
        
        md = sha.new()
        for thing in self.user.__dict__.values():
            md.update(str(thing))
            md.update(str(time.time()))
        self.hash = md.hexdigest()

        global INTERFACES
        while INTERFACES.has_key(self.hash):
            md.update(str(time.time()))
            self.hash = md.hexdigest()
        INTERFACES[ self.hash ] = self


    def __del__(self):
        print "DEL",self.hash
        global INTERFACES
        del INTERFACES[self.hash]


    def id(self):
        return self.hash


    def processWebForm(self,request):
        return 
